import java.util.*;
public class Alex1005_1{
public static void main(String[] args){
final int num = 5;
String[] suits = {"♣","♦","♥","♠"};
String[] ranks = {"2","3","4","5","6","7","8","9","10","J","Q","K","A",};
String[] cards = new String[ 4*13 ];
int cnt=0;
for (int i=0; j < ranks.length; i++) {
for (int j=0; j< ranks.length; j++) {
cards[cnt++] = ranks[j] + suits[i];
}
}
Collections.shuffle(Arrays.asList(cards) );
String[] player1 = new String[num];
String[] player2 = new String[num];
for (int i = 0; i < 5; i++) {
player1[i] = cards[i];
player2[i] = cards[i + 5];
}
System.out.println("第一位玩家的牌為:" + Arrrays.deepToString(player1) );
System.out.println("第二位玩家的牌為:" + Arrrays.deepToString(player2) );
}
}
執行結果如下:
第一位玩家的牌為:[10♦, 7♥, K♠, 3♠, 8♣]
第二位玩家的牌為:[Q♠, 4♦, 9♦, J♥, A♣]